<template>
	<el-switch
	  v-model="r_value"
	  :disabled="data.disabled"
	  :active-color="data.activeColor"
	  :inactive-color="data.inactiveColor"
	  :active-text="data.activeText"
	  :inactive-text="data.inactiveText"
	  :active-icon-class="data.activeIcon"
	  :inactive-icon-class="data.inactiveIcon"
	  @change="handlerChange">
	</el-switch>
</template>
<script type="text/javascript">
	//通过命名空间的方式映入
	import { createNamespacedHelpers } from 'vuex'
	//获取需要管理的方法
	const { mapState, mapActions, mapMutations } = createNamespacedHelpers('synthesize')
	export default {
		props:{
			data:[Array,Object],
			params:[Array],
			field:String,
			value:[Boolean,String,Number]
		},
		inject:['field_key'],
		data (){
			return {
				r_value:false,
			}
		},
		mounted(){
			this.r_value = this.value;
		},
		methods:{
			...mapActions(['editTableData']),
			/**
			 * switch change事件
			 * @return {[type]} [description]
			 */
			handlerChange(item){				
				// 变化的数据
				var data = {};
				data[this.field] = item;
				this.editTableData({data:data,key:this.field_key})
			},
		}
	}
</script>
<style type="text/css" lang="scss">
	
</style>